﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace linkDATABASE.扩展
{
    public partial class 添加房间 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string[] a = new string[] { "商务房", "标准房", "大床房","套房"};
            string[] b = new string[] { "住客房","空房"};
            DropDownList1.DataSource = a;
            DropDownList2.DataSource = b;
            
            DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string num = TextBox1.Text;
            string xing = DropDownList1.SelectedValue;
            string tai = DropDownList2.SelectedValue;
            string order_state = RadioButtonList1.SelectedValue;
            string bed_num = TextBox2.Text;
            string position = TextBox3.Text;

            string sqlstr = "insert into Roominfo (房号,房形,房态,预订状态,床位数,所处位置) " +
                "values('" + num + "', '" + xing + "', '" + tai + "', '" + order_state + "', " + bed_num + ", '" + position + "')";

            SqlConnection myConnection = new SqlConnection("Data Source=101.200.157.164;Initial Catalog=Hotel" +
                ";Persist Security Info=True;User ID=sa;Password=Jinghaoyang1");

            myConnection.Open();
            SqlCommand cmd = new SqlCommand(sqlstr, myConnection);
            cmd.ExecuteNonQuery();
            myConnection.Close();

            Response.Write(" <script>alert(\"成功添加房间!\") </script>");

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            SqlDataSource1.DataBind();

        }
    }
}